package org.hgvc.webapp.ets.jsf.beans.partner;

import org.hgvc.webapp.ets.bo.PartnerProduct;
import org.hgvc.webapp.ets.spring.service.PartnerService;
import org.jocsb.base.AbstractBean;
import org.jocsb.base.exception.BaseException;


public class PartnerProductApprovalBean extends AbstractBean{

	public static final String BEAN_NAME ="partnerProductApprovalBean";
	public static final String AB_APPROVED_INVOKE_METHOD="productApprovedInvokeAction";
	public static final String AB_REJECTED_INVOKE_METHOD="productRejectInvokeAction";
	public static final String NAV_PRODUCT_APPROVED="partnerProductAppr";
	public static final String NAV_PRODUCT_REJECTED="partnerProductRej";
	private PartnerProduct product;
	private PartnerService service;
	private String actionNo;
	public PartnerProduct getProduct() {
		return product;
	}
	public void setProduct(PartnerProduct product) {
		this.product = product;
	}
	public void setService(PartnerService service) {
		this.service = service;
	}
	/*-----------------------------------------------------------------------------------*/
	public String productApprovedInvokeAction(String actionNo,String... params){
		String productId = params[1];
		try{
			this.actionNo = actionNo;
			product = service.getPartnerProductById(productId);
		}catch(BaseException be){
			be.printStackTrace();
			initErrorBean(be);
		}
		return NAV_PRODUCT_APPROVED;
	}
	public String productRejectInvokeAction(String actionNo,String... params){
		String productId = params[1];
		try{
			this.actionNo = actionNo;
			product =  service.getPartnerProductById(productId);
		}catch(BaseException be){
			be.printStackTrace();
			initErrorBean(be);
		}
		return NAV_PRODUCT_REJECTED;
	}
	
	public String acknowledgeMessage(){
		try{
			service.ackPartnerProductMessage(actionNo);
		}catch(BaseException be){
			be.printStackTrace();
			initErrorBean(be);
		}
		return PartnerBean.NAV_PARTNER_PORTAL;
	}
}
